sources :=
include_dirs :=

objects = $(subst .c,.o, $(sources))
dependencies = $(subst .c,.d,$(sources))

CURRENTDIR := $(shell pwd)

include_dirs += -I $(CURRENTDIR)/include -I $(CURRENTDIR)/exported

CC := gcc
CFLAGS := --std=c99 -m32
LDFLAGS:=-fPIC -shared
#LIB:=-lgcc -lgcc_s -lc
AR :=ar
ARFLAGS :=rv
INCLUDE =  $(include_dirs)

MV := mv -f
RM := rm -f
SED := sed

all: 

include ecl/source/module.mk
include epp/source/module.mk
include hybridEIM/source/module.mk

.PHONY :all

all : libtcl.so
	
%.d : %.c 
	$(CC) -M $(CFLAGS) $(INCLUDE) $< > $@.$$$$; \
		$(SED) 's,\($(notdir $*)\.o[ : ]*,$(dir $@)\1.o $@ : ,g' < $@.$$$$ > $@; \
		$(RM) $@.$$$$


#libtcl.a: libtcl.a($(objects))
libtcl.so : $(objects)
	$(CC) $(LDFLAGS) $(CFLAGS) $(LIB) $^ -o $@


$(objects) : %.o:%.c
	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@

.PHONY: clean
clean:
	$(RM) $(objects) *.a *.so

